#include <iostream>

using namespace std;

const int N = 510;
int n, m;
char a[N][N];
int dp[N][N];

int get_score(int x,int y)
{
    if(a[x][y] == 'l') return 4;
    if(a[x][y] == 'o') return 3;
    if(a[x][y] == 'v') return 2;
    if(a[x][y] == 'e') return 1;
    return 0;
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            int t = get_score(i, j);
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + t;
        }
    }
    // cout << dp[1][1] << endl;
    cout << dp[n][m] << endl;
    return 0;
}
